package com.rockcent.service;

import com.rockcent.common.common.PageResult;
import com.rockcent.common.domain.enumclass.Whether;
import com.rockcent.mall.lib.domain.IntegrationCouponWallet;
import com.rockcent.mall.lib.domain.MerchantCoupon;
import com.rockcent.mall.lib.dto.IntegrationChannelDto;
import com.rockcent.mall.lib.dto.IntegrationCouponDetailRespDto;
import com.rockcent.mall.lib.dto.IntegrationCouponRespDto;
import com.rockcent.mall.lib.dto.IntegrationCouponWalletDto;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;

/**
 * Created by zhangjh on 2016/12/17.
 */
public interface IntegrationCouponWalletSrv {
    /**
     * @param exchangeCode
     * @param exchangeNum
     * @param receiveNum
     * @param useNum
     * @return
     */
    IntegrationCouponWallet findByExchangeCodeAndExchangeNumAndReceiveNumAndUseNum(String exchangeCode, long exchangeNum, long receiveNum, long useNum);

    /**
     * @param integrationCouponWallet
     * @return
     */
    IntegrationCouponWallet save(IntegrationCouponWallet integrationCouponWallet);

    /**
     * @param cashCouponId
     * @param integrationChannelId
     * @param mallId
     * @return
     */
    IntegrationCouponWallet caculateCoupon(Long cashCouponId, Long integrationChannelId, Long mallId);

    /**
     * @param dto
     * @param mallId
     * @param no
     * @param page
     * @return
     */
    PageResult<IntegrationCouponWalletDto> findChannelCouponDetail(IntegrationChannelDto dto, Long mallId, Whether no, PageResult page);

    /**
     * @param dto
     * @param mallId
     * @param no
     * @return
     */
    Long qrExchangeNumByChannelId(IntegrationChannelDto dto, Long mallId, Whether no);

    void exportExchangeCoupon(HttpServletRequest request, HttpServletResponse response, IntegrationChannelDto dto, Long mallId, Whether no) throws IOException, InvalidFormatException;

    /**
     * 停止发放优惠券，该状态
     *
     * @param merchantCouponId
     * @param mallId
     */
    void stop(Long merchantCouponId, Long mallId);

    /**
     * @param merchantCouponId
     * @param channelId
     * @param mallId
     * @param batchNo
     * @param merchantName
     */
    void updateIntegrationChannelId(Long merchantCouponId, Long channelId, Long mallId, Long batchNo, String merchantName);

    /**
     * @param coupon
     */
    void batchSave(MerchantCoupon coupon);

    /**
     * @param channelId
     * @return
     */
    List<IntegrationCouponRespDto> queryList(Long channelId);

    /**
     * @param exchangeCode
     * @return
     */
    IntegrationCouponWallet findByExchangeCode(String exchangeCode);

    /**
     * @param exchangeCode
     * @param channelId
     * @param no
     * @param exchangeNum
     * @return
     */
    IntegrationCouponWallet findByExchangeCodeAndIntegrationChannelIdAndIsDeleteAndExchangeNum(String exchangeCode, Long channelId, Whether no, long exchangeNum);

    /**
     * @param dto
     * @param mallId
     * @param no
     * @return
     */
    Double qrExchangeNumCouponAmountByChannelId(IntegrationChannelDto dto, Long mallId, Whether no);

    /**
     * @param id
     * @return
     */
    List<IntegrationCouponDetailRespDto> findByCounponId(Long id);

    /**
     * @param exchangeCode
     * @param integrationChannelId
     * @param no
     * @return
     */
    IntegrationCouponWallet findByExchangeCodeAndIntegrationChannelIdAndIsDelete(String exchangeCode, Long integrationChannelId, Whether no);

    /**
     * @param id
     * @param integrationChannelId
     * @param no
     * @param exchangenum
     * @return
     */
    IntegrationCouponWallet findTop1ByIdAndIntegrationChannelIdAndIsDeleteAndExchangeNum(Long id, Long integrationChannelId, Whether no, long exchangenum);
}
